package edu.scnu.fans.fingertip.user.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import edu.scnu.fans.fingertip.user.output.UserOutput;
import lombok.Data;

import java.time.Instant;

/**
 * 用户表
 */
@Data
@TableName("user")
public class User {

    @TableId(type = IdType.AUTO)
    private Long id;

    private Instant created;
    private Instant updated;
    private boolean deleted;

    /** 用户名 */
    private String username;
    /** 密码 */
    private String password;
    /** 昵称 */
    private String nickname;
    /** 头像图片 */
    private String img;
    /** 手机号 */
    private String mobile;
    /** 性别 1:男; 0:女 */
    private Integer gender;

    User() {
    }

    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public UserOutput transferToOutput() {
        return new UserOutput(id, created, updated, username, nickname, img, mobile, gender);
    }

}
